Slice in functions


    func updateSliceElement(a []int) {
        a[0] = 10
    }
    func appendIntoSlice(a []int) {
        a = append(a, 20)
    }

    func main() {
        var x = []int{1, 2, 3, 4, 5}
        updateSliceElement(x) // x = [10, 2, 3, 4, 5]
        appendIntoSlice(x) // x = [10, 2, 3, 4, 5]
    }

    /*
      on appending, the Go compiler
      1. if len == cap => creates a new block in the memory, which is not returned. And hence not known by the calling function.
      2. if len < cap => the memory block is still the same, but length value of the slice is still the same in the calling function. Hence, can't access outside it.
    */